package com.example.makerspace.controller.expert;


import com.example.makerspace.dto.*;
import com.example.makerspace.service.ExpertService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping(value = "/api/expert")
@Api(tags = "专家模块")
public class ExpertController {
    @Resource
    private ExpertService expertService;
    @ApiOperation(value="用户展示专家列表",notes ="用户展示专家列表说明")
    @PostMapping("/showExpertList")
    public Result showExpertList(@RequestBody PageRequest pageRequest){
        return  expertService.showExpertList(pageRequest);
    }

    @ApiOperation(value="产品列表接口",notes ="产品列表接口说明")
    @GetMapping("/productLists")
    public Result productLists(){
        return  expertService.productLists();
    }


    @ApiOperation(value="用户展示专家详情页接口-前台",notes ="用户展示专家详情页说明-前台")
    @GetMapping("/showExpertDetail")
    public Result showExpertDetail(@RequestParam("id") Integer id){
        return  expertService.showExpertDetail(id);
    }


    @ApiOperation(value="获取专家分类列表接口-前台",notes ="获取专家分类列表接口-前台说明")
    @GetMapping("/getExpertType")
    public Result getExpertType(){
        return  expertService.getExpertType();
    }

    @ApiOperation(value="增加专家接口-后台",notes ="增加专家接口说明-后台")
    @PostMapping("/addExpert")
    public Result addExpert(@RequestBody ExpertInfoDTO expertInfoDTO){
        return  expertService.addExpert(expertInfoDTO);
    }

    @ApiOperation(value="修改专家接口-后台",notes ="修改专家接口-后台")
    @PostMapping("/updateExpert")
    public Result updateExpert(@RequestBody ExpertInfoDTO  expertInfoDTO){
        return  expertService.updateExpert(expertInfoDTO);
    }

    @ApiOperation(value="删除专家接口-后台",notes ="删除专家接口-后台")
    @GetMapping("/deleteExpert")
    public Result deleteExpert(@RequestParam("id") Integer id){
        return  expertService.deleteExpert(id);
    }

    @ApiOperation(value="展示专家接口-后台",notes ="用户展示专家详情页说明-后台")
    @PostMapping("/getExpert")
    public Result getExpert(@RequestBody  PageRequest pageRequest){
        return  expertService.getExpert(pageRequest);
    }


    @ApiOperation(value="发送任务接口-后台",notes ="发送任务接口说明-后台")
    @PostMapping("/sendTask")
    public Result sendTask(@RequestBody ExpertTaskDTO expertTaskDTO){
        return  expertService.sendTask(expertTaskDTO);
    }

    @ApiOperation(value="查看特定任务下的成果列表页-前台",notes ="管理员-专家评审产品记录列表接口-前台")
    @PostMapping("/addTaskExpert")
    public Result addTaskExpert(@RequestBody ExpertTaskDTO expertTaskDTO){
        return  expertService.addTaskExpert(expertTaskDTO);
    }


    @ApiOperation(value="修改任务接口-后台",notes ="修改任务接口说明-后台")
    @PostMapping("/updateTask")
    public Result updateTask(@RequestBody ExpertTaskDTO expertTaskDTO){
        return  expertService.updateTask(expertTaskDTO);
    }

    @ApiOperation(value="删除任务接口-后台",notes ="发送任务接口说明-后台")
    @GetMapping("/deleteTask")
    public Result deleteTask(@RequestParam("id")Integer id){
        return  expertService.deleteTask(id);
    }

    @ApiOperation(value="查看专家的任务列表接口-后台",notes ="查看专家的任务列表接口-后台")
    @PostMapping("/listPageTask")
    public Result listPageTask(@RequestBody PageRequest pageRequest){
        return  expertService.listPageTask(pageRequest);
    }


    @ApiOperation(value="查看特定任务下的成果列表页-前台",notes ="管理员-专家评审产品记录列表接口-前台")
    @PostMapping("/listOutcome")
    public Result listOutcome(@RequestBody PageRequest pageRequest,HttpServletRequest request){
        return  expertService.listOutcome(pageRequest,request);
    }

    @ApiOperation(value="获取打分情况列表-前台",notes ="获取打分情况列表-前台")
    @GetMapping("/getScoreCondition")
    public Result getScoreCondition(HttpServletRequest request,@RequestParam("taskId")Integer taskId,
                                    @RequestParam("outcomeId")Integer outcomeId){
        return  expertService.getScoreCondition(request,taskId,outcomeId);
    }



    @ApiOperation(value="查看专家的任务列表接口-前台",notes ="查看专家的任务列表接口-前台")
    @GetMapping("/listTask")
    public Result listTask(HttpServletRequest request){
        return  expertService.listTask(request);
    }

    @ApiOperation(value="专家评审产品接口-前台",notes ="专家评审产品接口-前台")
    @PostMapping("/expertScore")
    public Result expertScore(@RequestBody ExpertProductScoreDTO expertProductScoreDTO){
        return  expertService.expertScore(expertProductScoreDTO);
    }


    @ApiOperation(value="专家修改评审结果接口-前台",notes ="专家修改评审结果接口-前台")
    @PostMapping("/expertUpdateScore")
    public Result expertUpdateScore(@RequestBody ExpertProductScoreDTO expertProductScoreDTO){
        return  expertService.expertUpdateScore(expertProductScoreDTO);
    }


    @ApiOperation(value="专家接受/拒绝任务-前台",notes ="专家接受/拒绝任务-前台")
    @GetMapping("/receiveTask")
    public Result receiveTask(@RequestParam("op") String op,@RequestParam("id") Integer id,HttpServletRequest request){
        return  expertService.receiveTask(op,id,request);
    }

    @ApiOperation(value="个人-专家评审产品记录列表接口-前台",notes ="个人-专家评审产品记录列表接口-前台")
    @PostMapping("/listExpertScore")
    public Result listExpertScore(@RequestBody PageRequest pageRequest,HttpServletRequest request){
        return  expertService.listExpertScore(pageRequest,request);
    }

    @ApiOperation(value="管理员-专家评审产品记录列表接口-前台",notes ="管理员-专家评审产品记录列表接口-前台")
    @PostMapping("/listAllExpertScore")
    public Result listAllExpertScore(@RequestBody ExpertProductScoreDTO expertProductScoreDTO){
        return  expertService.listAllExpertScore(expertProductScoreDTO);
    }


    @ApiOperation(value="成果列表-后台",notes ="成果列表-后台")
    @PostMapping("/showResults")
    public Result showResults(@RequestBody PageRequest pageRequest){
        return  expertService.showResults(pageRequest);
    }

    @ApiOperation(value="任务绑定成果接口-后台",notes ="成成果绑定任务接口-后台")
    @PostMapping("/taskBindOutcome")
    public Result taskBindOutcome(@RequestBody ExpertTaskDTO expertTaskDTO){
        return  expertService.taskBindOutcome(expertTaskDTO);
    }


    @ApiOperation(value="根据任务id获取成果和专家列表-后台",notes ="根据任务id获取成果和专家列表-后台")
    @GetMapping("/showOutcomeExpert")
    public Result showOutcomeExpert(@RequestParam("taskId")Integer taskId){
        return  expertService.showOutcomeExpert(taskId);
    }


    @GetMapping("/file/onlinePreview")
    public void onlinePreview(@RequestParam("url") String url, HttpServletResponse response) throws Exception{
        expertService.onlinePreview(url,response);
    }

    @ApiOperation(value="成果文件上传-后台",notes ="后果文件上传-后台")
    @PostMapping("/uploadFile")
    public Result uploadFile(@ModelAttribute ExpertOutcomeDTO expertOutcomeDTO) throws Exception{
        return  expertService.uploadFile(expertOutcomeDTO);
    }
    @ApiOperation(value="增加成果-后台",notes ="后果文件上传-后台")
    @PostMapping("/addOutCome")
    public Result addOutCome(@ModelAttribute ExpertOutcomeDTO expertOutcomeDTO) throws Exception{
        return  expertService.addOutCome(expertOutcomeDTO);
    }
    @ApiOperation(value="修改成果-后台",notes ="后果文件上传-后台")
    @PostMapping("/updateOutCome")
    public Result updateOutCome(@ModelAttribute ExpertOutcomeDTO expertOutcomeDTO) throws Exception{
        return  expertService.updateOutCome(expertOutcomeDTO);
    }
    @ApiOperation(value="删除成果-后台",notes ="后果文件上传-后台")
    @PostMapping("/deleteOutCome")
    public Result deleteOutCome(@RequestParam("id") Integer id) throws Exception{
        return  expertService.deleteOutCome(id);
    }

    @ApiOperation(value="任务添加专家接口-后台",notes ="任务添加专家接口-后台")
    @GetMapping("/taskBindExpert")
    public Result taskBindExpert(@RequestParam("id") Integer id,@RequestParam("username")String username,
                                 @RequestParam("name")String name) throws Exception{
        return  expertService.taskBindExpert(id,username,name);
    }




}
